
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.URL;
import javax.swing.JApplet;


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Highscore.java
 *
 * Created on Oct 15, 2011, 6:01:01 PM
 */
/**
 *
 * @author Riso-Desktop
 */
public class Highscore extends JApplet {

    /** Creates new form Highscore */
    static Skore_zoznam sz = new Skore_zoznam();

    @Override
    public void init() {
        initComponents();
        setSize(960, 600);
    }

    public Highscore() {

        initComponents();
        jTextArea1.setEditable(false);
        jTextArea1.setFocusable(false);
        nacitajskore();
    }

    public void ulozskore() {
        try {
            FileOutputStream fos = new FileOutputStream("score_data.dat");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(sz);
            oos.flush();
            oos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void nacitajskore() {
        try {
            try {
                FileInputStream fis = new FileInputStream("score_data.dat");
                ObjectInputStream ois = new ObjectInputStream(fis);
                sz = (Skore_zoznam) ois.readObject();

                ois.close();
                jTextArea1.setText(sz.toString());
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        } catch (IOException e) {
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        getContentPane().setLayout(null);

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setFont(new java.awt.Font("Times New Roman", 2, 24)); // NOI18N
        jTextArea1.setRows(5);
        jTextArea1.setFocusable(false);
        jTextArea1.setMargin(new java.awt.Insets(10, 10, 2, 2));
        jScrollPane1.setViewportView(jTextArea1);

        getContentPane().add(jScrollPane1);
        jScrollPane1.setBounds(250, 100, 456, 395);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/back_nestlac.png"))); // NOI18N
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setFocusPainted(false);
        jButton1.setMargin(null);
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/img/back_stlac.png"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);
        jButton1.setBounds(418, 515, 133, 52);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/high.png"))); // NOI18N
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 960, 600);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_jButton1ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables
}
